/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.ruby_string.delayed;


import moved.org.objectweb.asm.Label;
import moved.org.objectweb.asm.MethodVisitor;

import java.util.Arrays;

public class TableSwitchInstruction extends AbstractMethodInstruction {
	private final int min;
	private final int max;
	private final Label dflt;
	private final Label[] labels;

	public TableSwitchInstruction(int min, int max, Label dflt, Label[] labels) {
		this.min = min;
		this.max = max;
		this.dflt = dflt;
		this.labels = labels;
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// MethodInstruction Methods
	///////////////////////////////////////////////////////////////////////////////////////////////
	
	public void accept(MethodVisitor methodVisitor) {
		methodVisitor.visitTableSwitchInsn(min, max, dflt, labels);
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// Object Methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	@Override
	public boolean equals(Object object) {
		if (object == null || !(object.getClass().equals(getClass()))) {
			return false;
		}

		TableSwitchInstruction other = (TableSwitchInstruction) object;

		return min == other.min &&
			max == other.max &&
			dflt.equals(other.dflt) &&
			Arrays.equals(labels, other.labels);
	}
}
